package com.lyhengtongwl.zqsnews.adapter;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lyhengtongwl.zqsnews.R;
import com.lyhengtongwl.zqsnews.entity.EarnEntity;
import com.lyhengtongwl.zqsnews.utils.FTYUtils;

import java.util.List;

public class EarnAdapter extends BaseQuickAdapter<EarnEntity, BaseViewHolder> {
    private Activity activity;

    public EarnAdapter(Activity activity, List<EarnEntity> newsList) {
        super(R.layout.item_earn_1, newsList);
        this.activity = activity;
    }


    @SuppressLint("SetTextI18n")
    @Override
    protected void convert(BaseViewHolder helper, EarnEntity item) {
        String title = item.getTitle();
        String time = item.getTime();
        String money = item.getMoney();
        String inComeTypeId = item.getInComeTypeId() + "";
        if ("".equals(item.getTitle_1())) {
            ((TextView) helper.getView(R.id.tv_title)).setText(title);
        } else {
            ((TextView) helper.getView(R.id.tv_title)).setText(item.getTitle_1());
        }
        ((TextView) helper.getView(R.id.tv_tag)).setText(item.getTag());
        if (!"".equals(time) && time != null)
            ((TextView) helper.getView(R.id.tv_time)).setText(time.substring(5));
        switch (inComeTypeId) {
            case "666":
                ((TextView) helper.getView(R.id.tv_money)).setText("-" + FTYUtils.fenToYuan(money));
                break;
            default:
                ((TextView) helper.getView(R.id.tv_money)).setText("+" + FTYUtils.fenToYuan(money));
                break;
        }

    }
}
